﻿using System.Collections.Generic;
using ECG.Common;

namespace ECG.DAL
{
    public partial class ConfigDb
    {
 
        public static List<ConfigDto> GetAll()
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Client_Config_GetAll");
            try
            {
                return dao.GetDTOList<ConfigDto>(ref command);
            }
            finally
            {
                command.Connection.Close();
            }
        }

        public static int Add(ConfigDto model)
        {
            var dao = SharedSqlDao;
            var command = dao.GetDbSprocCommand("WSPX_Client_Config_Add");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@Key", model.Key));
                command.Parameters.Add(dao.CreateParameter("@Value", model.Value));
                command.Parameters.Add(dao.CreateParameter("@Description", model.Description));
                command.Parameters.Add(dao.CreateParameter("@Type", model.Type));
                return (int)command.ExecuteScalar();
            }
            finally
            {
                command.Connection.Close();
            }
        }
    }
}
